﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace ChungNhanSinhVien
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "GhiNhanYeuCau",
                "gnyc",
                new { controller = "YeuCau", action = "GhiNhanYeuCau" }
                );

            routes.MapRoute(
                "XemKetQuaGhiNhan",
                "kqgn",
                new { controller = "YeuCau", action = "XemKetQuaGhiNhan" }
                );

            routes.MapRoute(
                "Thoat",
                "t",
                new { controller = "DangNhap", action = "Thoat" }
                );

            #region Admin            
            routes.MapRoute(
                "Admin",
                "cnsvdtt",
                new { controller = "DangNhap", action = "Index" }
                );

            routes.MapRoute(
                "GhiTra",
                "nsr/gtr",
                new { controller = "Ad_YeuCau", action = "GhiTraYeuCau" }
                );

            routes.MapRoute(
                "AdminLayYeuCau",
                "nsr/lyc",
                new { controller = "Ad_YeuCau", action = "LayYeuCau" }
                );

            routes.MapRoute(
                "CapNhatChungNhan",
                "nsr/cncn",
                new { controller = "Ad_ChungNhan", action = "XemChungNhanTheoLoaiCN" }
                );

            routes.MapRoute(
                "HuyYeuCau",
                "hyc/{id}",
                new { controller = "YeuCau", action = "HuyYeuCau", id = UrlParameter.Optional }
                );

            routes.MapRoute(
                "AdminCapNhatYeuCau",
                "nsr/cnyc",
                new { controller = "Ad_YeuCau", action = "CapNhatKetQuaXuLy" }
                );

            routes.MapRoute(
                "DoiMK",
                "nsr/mk",
                new { controller = "Account", action = "DoiMatKhau" }
                );

            routes.MapRoute(
                "ThoatAdmin",
                "ta",
                new { controller = "DangNhap", action = "ThoatAdmin" }
                );

            #region Cập nhật chứng nhận
            routes.MapRoute(
                "TaoMoiLoaiCN",
                "taoloaicn",
                new { controller = "Ad_ChungNhan", action = "TaoMoiLoaiCN" }
                );

            routes.MapRoute(
                "SuaLoaiCN",
                "sualoaicn/{id}",
                new { controller = "Ad_ChungNhan", action = "SuaLoaiCN", id = UrlParameter.Optional }
                );

            routes.MapRoute(
                "XoaLoaiCN",
                "xoaloaicn/{id}",
                new { controller = "Ad_ChungNhan", action = "XoaLoaiCN", id = UrlParameter.Optional }
                );

            routes.MapRoute(
                "TaoMoiCN",
                "taocn",
                new { controller = "Ad_ChungNhan", action = "TaoMoiCN" }
                );

            routes.MapRoute(
                "SuaCN",
                "suacn/{id}",
                new { controller = "Ad_ChungNhan", action = "SuaCN", id = UrlParameter.Optional }
                );

            routes.MapRoute(
                "XoaCN",
                "xoacn/{id}",
                new { controller = "Ad_ChungNhan", action = "XoaCN", id = UrlParameter.Optional }
                );

            #endregion

            #endregion
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}", // URL with parameters
                //"{controller}/{action}/{id}", // URL with parameters
                //new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                //new { controller = "DangNhap", action = "Index" }
                //new { controller = "Account", action = "DoiMatKhau" }                
                new { controller = "YeuCau", action = "GhiNhanYeuCau" }
            );
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}